<?php
$currentDate = date_parse(date("Y-m-d"));
?>
<h3>Welcome <?php
    echo($_SESSION['userName']);
    ?> your schedule history is: </h3>
<?php
$err = new ErrorCode();
$shiftsOffered = viewMySchedule(
        $_SESSION['userName'], $_SESSION['userPassHash']);

if ($shiftsOffered['0'] == $err::successRead) {
    ?>
    <table class="table table-condensed table-striped">
        <thead>
            <tr>
                <th>Role Name</th>
                <th>Date</th>
                <th>Start Time</th>
                <th>End Time</th>
            </tr>
        </thead>
        <tbody>
            <?php
            for ($i = 1; $i < count($shiftsOffered); $i++) {
                if (date_parse($shiftsOffered[$i]["date"]) < $currentDate) {
                    ?><tr>
                        <td><?php echo($shiftsOffered[$i]["roleName"]); ?></td>
                        <td><?php echo($shiftsOffered[$i]["date"]); ?></td>
                        <td><?php echo($shiftsOffered[$i]["startTime"]); ?></td>
                        <td><?php echo($shiftsOffered[$i]["endTime"]); ?></td>
                    </tr>
                    <?php
                }
            }
            ?>
    </table>
    <?php
} else {
    //can display the error message here if needed 
    ?>No shifts were found.<?php
}
?>